﻿<Window x:Class="TicketServer.SettingsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:eT="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended"
        xmlns:p="clr-namespace:TicketServer.Properties"
        Title="{LocText TicketServer:SettingsWindow:WindowTitle}"
        Width="600"
        Height="480"
        Closed="Window_Closed"
        Icon="/TicketServer;component/Icons/Small/Service Manager.png"
        ResizeMode="NoResize"
        ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner"
        WindowStyle="SingleBorderWindow">
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="200" />
			<ColumnDefinition />
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition />
			<RowDefinition Height="34" />
		</Grid.RowDefinitions>

		<ListBox x:Name="listBoxPage"
		         Grid.Row="0"
		         Grid.Column="0"
		         Margin="5"
		         SelectionChanged="listBoxPage_SelectionChanged">
			<ListBoxItem IsSelected="True">
				<StackPanel Margin="0 2" Orientation="Horizontal">
					<Image Width="24" Source="Icons\Medium\vcard.png" />
					<TextBlock Margin="5 0 0 0"
					           VerticalAlignment="Center"
					           Text="{LocText TicketServer:SettingsWindow:Tickets}" />
				</StackPanel>
			</ListBoxItem>
			<ListBoxItem>
				<StackPanel Margin="0 2" Orientation="Horizontal">
					<Image Width="24" Source="Icons\Medium\db.png" />
					<TextBlock Margin="5 0 0 0"
					           VerticalAlignment="Center"
					           Text="{LocText TicketServer:SettingsWindow:DataSource}" />
				</StackPanel>
			</ListBoxItem>
		</ListBox>

		<TabControl x:Name="tabControlSettings"
		            Grid.Row="0"
		            Grid.Column="1"
		            Margin="5 3 5 5">
			<TabItem Visibility="Collapsed">
				<StackPanel>
					<GroupBox Margin="5"
					          FontWeight="Bold"
					          Header="{LocText TicketServer:SettingsWindow:groupSpecialTickets}">
						<Grid Margin="3">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="100" />
								<ColumnDefinition Width="180" />
								<ColumnDefinition Width="*" />
							</Grid.ColumnDefinitions>
							<Grid.RowDefinitions>
								<RowDefinition />
								<RowDefinition Height="32" />
								<RowDefinition />
							</Grid.RowDefinitions>

							<TextBlock Grid.Row="0"
							           Grid.Column="0"
							           Grid.ColumnSpan="3"
							           FontWeight="Normal"
							           Text="{LocText TicketServer:SettingsWindow:groupSpecialTicketsHeader}" />

							<TextBlock Grid.Row="1"
							           Grid.Column="0"
							           HorizontalAlignment="Right"
							           VerticalAlignment="Center"
							           FontWeight="Normal"
							           Text="{LocText TicketServer:SettingsWindow:groupSpecialTicketsString}" />
							<TextBox x:Name="textBoxSpecialCards"
							         Grid.Row="1"
							         Grid.Column="1"
							         Margin="4"
							         Text="{Binding SpecialTicketsString,
							                        Source={x:Static p:Settings.Default},
							                        Mode=TwoWay}" />

							<TextBlock Grid.Row="2"
							           Grid.Column="1"
							           Grid.ColumnSpan="2"
							           FontSize="10"
							           FontWeight="Normal"
							           Text="{LocText TicketServer:SettingsWindow:groupSpecialTicketsFooter}" />
						</Grid>
					</GroupBox>
				</StackPanel>
			</TabItem>
			<TabItem Visibility="Collapsed">
				<ScrollViewer VerticalScrollBarVisibility="Auto">
					<StackPanel>
						<GroupBox Margin="5"
						          FontWeight="Bold"
						          Header="{LocText TicketServer:SettingsWindow:groupBackup}">
							<StackPanel>
								<GroupBox Margin="5" FontWeight="Bold">
									<GroupBox.Header>
										<CheckBox x:Name="checkBoxBackupFolder"
										          Content="{LocText TicketServer:SettingsWindow:groupBackupFolder}"
										          IsChecked="{Binding FileBackup,
										                              Source={x:Static p:Settings.Default},
										                              Mode=TwoWay}" />
									</GroupBox.Header>
									<Grid Margin="5" IsEnabled="{Binding IsChecked, ElementName=checkBoxBackupFolder}">
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="Auto" />
											<ColumnDefinition Width="*" />
											<ColumnDefinition Width="Auto" />
										</Grid.ColumnDefinitions>
										<Grid.RowDefinitions>
											<RowDefinition />
											<RowDefinition />
										</Grid.RowDefinitions>

										<TextBlock Grid.Row="0"
										           Grid.Column="0"
										           HorizontalAlignment="Right"
										           VerticalAlignment="Center"
										           Text="{LocText TicketServer:SettingsWindow:groupBackupInterval}" />
										<eT:ButtonSpinner Grid.Row="0"
										                  Grid.Column="1"
										                  Margin="3"
										                  Spin="ButtonSpinner_Spin">
											<TextBox Text="{Binding FileBackupInterval, Source={x:Static p:Settings.Default}, Mode=TwoWay}" />
										</eT:ButtonSpinner>
										<TextBlock Grid.Row="0"
										           Grid.Column="2"
										           Margin="3"
										           HorizontalAlignment="Left"
										           VerticalAlignment="Center"
										           Text="{LocText TicketServer:SettingsWindow:groupBackupMinutes}" />

										<TextBlock Grid.Row="1"
										           Grid.Column="0"
										           HorizontalAlignment="Right"
										           VerticalAlignment="Center"
										           Text="{LocText TicketServer:SettingsWindow:groupBackupTargetFolder}" />
										<TextBox Grid.Row="1"
										         Grid.Column="1"
										         Margin="3"
										         Text="{Binding FileBackupFolder,
										                        Source={x:Static p:Settings.Default},
										                        Mode=TwoWay}" />
										<Button x:Name="buttonBrowse"
										        Grid.Row="1"
										        Grid.Column="2"
										        Margin="3"
										        Click="buttonBrowse_Click"
										        Content="..." />
									</Grid>
								</GroupBox>
								<eT:BusyIndicator x:Name="busyIndicatorFTP" BusyContent="{LocText TicketServer::PleaseWait}">
									<GroupBox Margin="5" FontWeight="Bold">
										<GroupBox.Header>
											<CheckBox x:Name="checkBoxBackupFTP"
											          Content="{LocText TicketServer:SettingsWindow:groupBackupFTP}"
											          IsChecked="{Binding FTPBackup,
											                              Source={x:Static p:Settings.Default},
											                              Mode=TwoWay}" />
										</GroupBox.Header>

										<Grid Margin="5" IsEnabled="{Binding IsChecked, ElementName=checkBoxBackupFTP}">
											<Grid.ColumnDefinitions>
												<ColumnDefinition Width="Auto" />
												<ColumnDefinition Width="*" />
												<ColumnDefinition Width="Auto" />
											</Grid.ColumnDefinitions>
											<Grid.RowDefinitions>
												<RowDefinition />
												<RowDefinition />
												<RowDefinition />
												<RowDefinition />
												<RowDefinition />
												<RowDefinition />
											</Grid.RowDefinitions>

											<TextBlock Grid.Row="0"
											           Grid.Column="0"
											           HorizontalAlignment="Right"
											           VerticalAlignment="Center"
											           Text="{LocText TicketServer:SettingsWindow:groupBackupInterval}" />
											<eT:ButtonSpinner Grid.Row="0"
											                  Grid.Column="1"
											                  Margin="3"
											                  Spin="ButtonSpinner_Spin">
												<TextBox Text="{Binding FTPBackupInterval, Source={x:Static p:Settings.Default}, Mode=TwoWay}" />
											</eT:ButtonSpinner>
											<TextBlock Grid.Row="0"
											           Grid.Column="2"
											           Margin="3"
											           HorizontalAlignment="Left"
											           VerticalAlignment="Center"
											           Text="{LocText TicketServer:SettingsWindow:groupBackupMinutes}" />

											<TextBlock Grid.Row="1"
											           Grid.Column="0"
											           HorizontalAlignment="Right"
											           VerticalAlignment="Center"
											           Text="{LocText TicketServer:SettingsWindow:groupBackupServer}" />
											<TextBox Grid.Row="1"
											         Grid.Column="1"
											         Margin="3"
											         Text="{Binding FTPBackupServer,
											                        Source={x:Static p:Settings.Default},
											                        Mode=TwoWay}" />

											<TextBlock Grid.Row="2"
											           Grid.Column="0"
											           HorizontalAlignment="Right"
											           VerticalAlignment="Center"
											           Text="{LocText TicketServer:SettingsWindow:groupBackupUser}" />
											<TextBox Grid.Row="2"
											         Grid.Column="1"
											         Margin="3"
											         Text="{Binding FTPBackupUser,
											                        Source={x:Static p:Settings.Default},
											                        Mode=TwoWay}" />

											<TextBlock Grid.Row="3"
											           Grid.Column="0"
											           HorizontalAlignment="Right"
											           VerticalAlignment="Center"
											           Text="{LocText TicketServer:SettingsWindow:groupBackupPassword}" />
											<PasswordBox x:Name="passwordBoxFTP"
											             Grid.Row="3"
											             Grid.Column="1"
											             Margin="3" />

											<TextBlock Grid.Row="4"
											           Grid.Column="0"
											           HorizontalAlignment="Right"
											           VerticalAlignment="Center"
											           Text="{LocText TicketServer:SettingsWindow:groupBackupTargetFolder}" />
											<TextBox Grid.Row="4"
											         Grid.Column="1"
											         Margin="3"
											         Text="{Binding FTPBackupFolder,
											                        Source={x:Static p:Settings.Default},
											                        Mode=TwoWay}" />
											<Button x:Name="buttonBrowseFTP"
											        Grid.Row="4"
											        Grid.Column="2"
											        Margin="3"
											        Click="buttonBrowseFTP_Click"
											        Content="..."
											        Visibility="Collapsed" />

											<Button x:Name="buttonTestFTP"
											        Grid.Row="5"
											        Grid.Column="1"
											        Margin="3"
											        Click="buttonTestFTP_Click"
											        Content="{LocText TicketServer:SettingsWindow:groupBackupFTPTest}" />
										</Grid>
									</GroupBox>
								</eT:BusyIndicator>
								<StackPanel Orientation="Horizontal">
									<TextBlock Margin="5" Text="{LocText TicketServer:SettingsWindow:groupBackupAttention}" />
									<TextBlock Margin="5"
									           FontWeight="Normal"
									           Text="{LocText TicketServer:SettingsWindow:groupBackupAttentionText}" />
								</StackPanel>
							</StackPanel>
						</GroupBox>
					</StackPanel>
				</ScrollViewer>
			</TabItem>
		</TabControl>

		<StackPanel Grid.Row="1"
		            Grid.Column="1"
		            HorizontalAlignment="Right"
		            Orientation="Horizontal">
			<Button x:Name="buttonSave"
			        Width="100"
			        Margin="5"
			        Click="buttonSave_Click"
			        Content="{LocText TicketServer:SettingsWindow:ButtonSave}" />
			<Button x:Name="buttonCancel"
			        Width="100"
			        Margin="5"
			        Click="buttonCancel_Click"
			        Content="{LocText TicketServer:SettingsWindow:ButtonCancel}" />
		</StackPanel>
	</Grid>
</Window>
